package com.wl4837;

// 手机工厂类
class PhoneFactory {
    // 静态工厂方法
    public static Phone createPhone(String brand) {
        if (brand == null || brand.isEmpty()) {
            return null;
        }

        return switch (brand.toLowerCase()) {
            case "huawei" -> new HuaweiPhone();
            case "xiaomi" -> new XiaomiPhone();
            case "iphone" -> new IPhone();
            default -> throw new IllegalArgumentException("未知手机品牌: " + brand);
        };
    }
}
